package vl05.logging;

import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LoggerTest {

	public static final String LOGNAME = LoggerTest.class.getSimpleName();
	private Logger log = null;
	
	public static void main(String[] args) {

		LoggerTest lt = new LoggerTest();
		lt.testLogger();
		
	}
	
	private LoggerTest(){
		log = Logger.getLogger(this.getClass().getSimpleName());
		log.setLevel(Level.INFO);
		
		Handler[] defHandler = Logger.getLogger("").getHandlers();
		
		if(defHandler.length == 1){
			defHandler[0].setLevel(Level.INFO);
		}
		
		try{
			Handler logHandler = new FileHandler("%h/Desktop/"+LOGNAME+"_%u"+"%g"+".log",1000000,3);
			logHandler.setLevel(Level.FINE);
			log.addHandler(logHandler);
		}
		catch (Exception e){}
	}
	
	private void testLogger(){
		log.fine("test_fine");
		log.info("test_info");
		log.warning("test_warning");
	}

}
